
import React, { Component } from 'react';
import {
    AppRegistry,
    StyleSheet,
    Text,
    Image,
    View,
    Button,
    TextInput,
    TouchableOpacity
} from 'react-native';


export default class Page3 extends React.Component {


  constructor(props) {
    super(props);
//    this.state = {
//      mode: "",
//    };
  }


    _onChangeText = (text)=>{
        this.props.navigation.setParams({title:text})
    }

  componentDidMount() {
//        const mode=navigation.getParam('edit', 'done'); // todo  this.props.navigation.getParam(paramName, defaultValue)

    }

    render() {
        const {navigation} = this.props;
        const {state, setParams} = navigation;
        const {params} = state;

        const showText = params.mode === 'edit' ? '正在编辑' : '编辑完成';

        return <View >
            <Text >欢迎来到Page3</Text>
            <Text >{showText}</Text>

            <TextInput
                // params 传送 过来的参数
                // setParams 自己更新自己的参数
//                onChangeText={text=>{
//                    setParams({title:text})
//                }}
                 onChangeText={this._onChangeText}
            />
            <Button
                title="Go Back"
                onPress={() => {
                    navigation.goBack();
                }}
            />
        </View>
    }
}